package com.example.lenovo.a203_yhy_ordering_3.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lenovo.a203_yhy_ordering_3.R;
import com.example.lenovo.a203_yhy_ordering_3.beans.FoodCommentBean;
import com.example.lenovo.a203_yhy_ordering_3.beans.FoodListBean;
import com.example.lenovo.a203_yhy_ordering_3.viewholder.FoodCommentViewHolder;
import com.example.lenovo.a203_yhy_ordering_3.viewholder.FoodListViewHolder;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lenovo on 2018/12/2.
 */

public class FoodCommentAdapter extends RecyclerView.Adapter<FoodCommentViewHolder>{
    private List<FoodCommentBean> list;

    @NonNull
    @Override
    public FoodCommentViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
        View view = layoutInflater.inflate(R.layout.food_comment_item,viewGroup,false);
        FoodCommentViewHolder viewHolder = new FoodCommentViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull FoodCommentViewHolder foodCommentViewHolder, int i) {
        final FoodCommentBean foodCommentBean = list.get(i);

//        foodCommentViewHolder.textView9.setText(foodCommentBean.getUsername());
        foodCommentViewHolder.textView9.setText("yin");
        foodCommentViewHolder.textView10.setText(foodCommentBean.getComment_time());
        foodCommentViewHolder.textView11.setText(foodCommentBean.getContent());
    }

    @Override
    public int getItemCount() {
        if(list!=null)
            return list.size();
        else
            return 0;
    }

    //自定义 设置数据list
    public void setList(List<FoodCommentBean> list)
    {
        this.list=list;
        notifyDataSetChanged();//通知RV刷新数据
    }
}
